`timescale 1ns/1ps
module GreenLED(Ac, clk, rst, GLED);
  input Ac;    //Access: 0 = access denied, 1 = access allowed
  input clk;   //clock: the clock from the system(security door system)
  input rst;   //rst: the reset bit
  output GLED; //Green LED: high when the green LED should be lit, low otherwise
  
  wire Ac;
  wire clk;
  wire GLED;
  wire rst;
  reg[23:0] count;
  
  always @ (posedge clk or posedge rst)
  if(rst == 1'b1)
  begin
    if(Ac == 1'b1 && count == 0)    //if access is allowed
    begin
      GLED = 1'b1;
      count <= count + 1;
    end
    elsif(count <= 1E7)
    begin
      GLED = 1'b1;
      count <= count + 1;
    end
    else
    begin
      //otherwise GLED is always off
      GLED = 1'b0;
      count <= 0;
    end
  end
  else
  begin
    count <= 0;
    GLED = 1'b0;
  end
  endmodule
